package com.example.sxproject.service.impl;

import com.example.sxproject.mapper.PaymentMapper;
import com.example.sxproject.pojo.Payment;
import com.example.sxproject.pojo.SearchStr;
import com.example.sxproject.service.PaymentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PaymentServiceImpl implements PaymentService {


   @Autowired
   private PaymentMapper paymentMapper;

    //管理员看全部账单
    @Override
    public List<Payment> selectAll() {
        List<Payment> payments=paymentMapper.selectAll();
        return payments;
    }

    //检索特定流水号
    @Override
    public List<Payment> selectByIdNumber(String idNumber){
        List<Payment> payments=paymentMapper.selectByIdNumber(idNumber);
        return payments;
    }

    @Override
    public List<Payment> selectBySearchStr(SearchStr searchStr){
        List<Payment> payments=paymentMapper.selectBySearchStr(searchStr);
        return payments;
    }

    //添加：添加一个记录
    @Override
    public void addPayment(Payment payment) {
        paymentMapper.addPayment(payment);
    }

    //更新：支付记录假删除
    @Override
    public void deletePayment(Payment payment) {
        paymentMapper.deletePayment(payment);
    }

    //查询：通过userId查询支付记录
    @Override
    public List<Payment> getPaymentsByUserId(Integer userId) {
        return paymentMapper.getPaymentsByUserId(userId);
    }

    //管理员更新
    @Override
    public  void paymentMessageUpdate(Payment payment){paymentMapper.paymentMessageUpdate(payment);}

    //管理员假删除
    @Override
    public void PaymentDl(Integer id) {
        paymentMapper.PaymentDl(id);
    }

}
